<template>
  <div id="app">
    <el-table
      :data="tableData"
      border
      style="width: 100%"
      stripe
      :header-cell-style="{ background: '#f7f7f7', color: '#1f6aa1' }"
    >
      <!-- <el-table-column type="index" /> -->
      <el-table-column prop="id" width="80" label="Id" />
      <el-table-column prop="username" label="用户名" />
      <el-table-column prop="ip" label="ip" />
      <el-table-column prop="content" label="内容" />
      <el-table-column prop="operation_time" label="操作时间" />
    </el-table>
    <el-pagination
      class="pagination"
      @current-change="current"
      @prev-click="prev"
      @next-click="next"
      background
      layout="prev, pager, next"
      :total="total"
      :page-size="size"
    >
    </el-pagination>
  </div>
</template>

<script>
import { toRefs, reactive, onMounted } from "vue";
import requst from "../../http/request";
export default {
  setup() {
    const list = reactive({
      tableData: [],
      page: 1,
      size: 10,
      total: null,
    });
    const getlist=async (page,size) => {
      const { data } = await requst.getLogs({
        page,
        size
      });

      list.tableData =data.data;
      list.total=data.total_count;
    }
    onMounted(getlist(list.page,list.size));
  
    const current=(val)=>{
        getlist(val,list.size)
    }
    const prev=(val)=>{
        getlist(val,list.size)
    }
    const next=(val)=>{
        getlist(val,list.size)
    }
    return {
      ...toRefs(list),
      current,
      prev,
      next
    };
  },
};
</script>

<style scoped>
#app {
  background: #f8f8f8;
  width: 100%;
  padding: 10px;
}
.pagination {
  justify-content: center;
  margin: 20px 0;
}
</style>